import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2023-12-04
 * Time: 8:44
 */
public class test {
    public static void main(String[] args) {
        int[] arr=new int[]{2,3,4,5,6,7,0,0,0};
        int[] arr1=new int[]{1,8,9};
        int a=5;
        int a1= arr1.length-1;
        int k=arr.length-1;
        while (a>0&&a1>0){
            if(arr[a]>arr1[a1]){
                arr[k]=arr[a];
                k--;
                a--;
            }else {
                arr[k]=arr1[a1];
                k--;
                a1--;
            }
        }
        while(a>=0){
            arr[k]=arr[a];
            k--;
            a--;
        }
        while(a1>=0){
            arr[k]=arr1[a1];
            k--;
            a1--;
        }
        System.out.println(Arrays.toString(arr));
    }
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) {
            // 注意 while 处理多个 case
            String str = in.nextLine();
            String str1 = func(str);
            System.out.println(str1);
        }
    }
    public static String func(String str) {
        StringBuilder sb = new StringBuilder();
        int[] arr=new int[127];
        for (int i = 0; i < str.length(); i++) {
            char ch=str.charAt(i);
            if(arr[ch]==0){
                sb.append(ch);
                arr[ch]=1;
            }
        }
        return str.toString();
    }
    public static void main1(String[] args) {
        int[] a=new int[]{4,5,6,0,0,0};
        int[] b=new int[]{1,2,3};
        int n=3;
        int m=0;
        while(m<3&&n<a.length){
            a[n]=b[m];
            m++;
            n++;
        }
        for(int i=0;i<n-1;i++){
            for(int j=0;j<n-1-i;j++){
                if (a[j]>a[j+1]){
                    int tmp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=tmp;
                }
            }
        }
        System.out.println(Arrays.toString(a));

    }
}